package com.augurit.gzcgwsp.sendNotice.exchangedatatofx.util;

import java.lang.reflect.Method;

import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.CsshljczForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.ShljYsForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwGgcsForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwHwShSqbForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwHwShljqsForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwRqQyjyxkForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwRqQyzzInfoForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwRqSsgdSqbForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwSrCsdlwjForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwSrDlzyForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwYnJzfqwczcJbxxForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwYnJzfqwczzPfsnForFx;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwYnJzfqwczzXnForFx;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class NullConverter implements Converter{

	public void marshal(Object source, HierarchicalStreamWriter writer,
			MarshallingContext context) {		
		String yw = source.getClass().getName();
		int i = yw.lastIndexOf(".");
		System.out.println("         i = "+i);
		System.out.println("         yw = "+yw);
		String yw2 = yw.substring(i + 1);
		System.out.println("         yw2 = "+yw2);
		if("YwRqSsgdSqbForFx".endsWith(yw2)){
			Method[] methods = YwRqSsgdSqbForFx.class.getMethods();
			YwRqSsgdSqbForFx obj = (YwRqSsgdSqbForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}
		}else if("CsshljczForFx".endsWith(yw2)){
			Method[] methods = CsshljczForFx.class.getMethods();
			CsshljczForFx obj = (CsshljczForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("ShljYsForFx".endsWith(yw2)){
			Method[] methods = ShljYsForFx.class.getMethods();
			ShljYsForFx obj = (ShljYsForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwGgcsForFx".endsWith(yw2)){
			Method[] methods = YwGgcsForFx.class.getMethods();
			YwGgcsForFx obj = (YwGgcsForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwHwShljqsForFx".endsWith(yw2)){
			Method[] methods = YwHwShljqsForFx.class.getMethods();
			YwHwShljqsForFx obj = (YwHwShljqsForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwHwShSqbForFx".endsWith(yw2)){
			Method[] methods = YwHwShSqbForFx.class.getMethods();
			YwHwShSqbForFx obj = (YwHwShSqbForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwRqQyjyxkForFx".endsWith(yw2)){
			Method[] methods = YwRqQyjyxkForFx.class.getMethods();
			YwRqQyjyxkForFx obj = (YwRqQyjyxkForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwRqQyzzInfoForFx".endsWith(yw2)){
			Method[] methods = YwRqQyzzInfoForFx.class.getMethods();
			YwRqQyzzInfoForFx obj = (YwRqQyzzInfoForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwSrCsdlwjForFx".endsWith(yw2)){
			Method[] methods = YwSrCsdlwjForFx.class.getMethods();
			YwSrCsdlwjForFx obj = (YwSrCsdlwjForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwSrDlzyForFx".endsWith(yw2)){
			Method[] methods = YwSrDlzyForFx.class.getMethods();
			YwSrDlzyForFx obj = (YwSrDlzyForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwYnJzfqwczcJbxxForFx".endsWith(yw2)){
			Method[] methods = YwYnJzfqwczcJbxxForFx.class.getMethods();
			YwYnJzfqwczcJbxxForFx obj = (YwYnJzfqwczcJbxxForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwYnJzfqwczzPfsnForFx".endsWith(yw2)){
			Method[] methods = YwYnJzfqwczzPfsnForFx.class.getMethods();
			YwYnJzfqwczzPfsnForFx obj = (YwYnJzfqwczzPfsnForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}else if("YwYnJzfqwczzXnForFx".endsWith(yw2)){
			Method[] methods = YwYnJzfqwczzXnForFx.class.getMethods();
			YwYnJzfqwczzXnForFx obj = (YwYnJzfqwczzXnForFx)source;
			for(Method m : methods){
				String methodName = m.getName();
				if (methodName.indexOf("get") != -1 && methodName != "getClass") {
					String name = methodName.substring(3);
					Object o = null;
					try {
						o = m.invoke(obj, new Object[0]);
					} catch (Exception e) {
						e.printStackTrace();
					}				
					writer.startNode(name);
					writer.setValue(o==null?"":o.toString());
					writer.endNode();			
				}
			}			
		}		
	}

	public Object unmarshal(HierarchicalStreamReader reader,
			UnmarshallingContext context) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean canConvert(Class type) {
		// TODO Auto-generated method stub
		System.out.println("type = "+type);
		if(type.equals(YwRqSsgdSqbForFx.class)){
			return type.equals(YwRqSsgdSqbForFx.class);
		}else if(type.equals(CsshljczForFx.class)){
			return type.equals(CsshljczForFx.class);
		}else if(type.equals(ShljYsForFx.class)){
			return type.equals(ShljYsForFx.class);
		}else if(type.equals(YwGgcsForFx.class)){
			return type.equals(YwGgcsForFx.class);
		}else if(type.equals(YwHwShljqsForFx.class)){
			return type.equals(YwHwShljqsForFx.class);
		}else if(type.equals(YwHwShSqbForFx.class)){
			return type.equals(YwHwShSqbForFx.class);
		}else if(type.equals(YwRqQyjyxkForFx.class)){
			return type.equals(YwRqQyjyxkForFx.class);
		}else if(type.equals(YwRqQyzzInfoForFx.class)){
			return type.equals(YwRqQyzzInfoForFx.class);
		}else if(type.equals(YwSrCsdlwjForFx.class)){
			return type.equals(YwSrCsdlwjForFx.class);
		}else if(type.equals(YwSrDlzyForFx.class)){
			return type.equals(YwSrDlzyForFx.class);
		}else if(type.equals(YwYnJzfqwczcJbxxForFx.class)){
			return type.equals(YwYnJzfqwczcJbxxForFx.class);
		}else if(type.equals(YwYnJzfqwczzPfsnForFx.class)){
			return type.equals(YwYnJzfqwczzPfsnForFx.class);
		}else if(type.equals(YwYnJzfqwczzXnForFx.class)){
			return type.equals(YwYnJzfqwczzXnForFx.class);
		}
		return type.equals(YwRqQyzzInfoForFx.class);
	}

}
